'''
Created on Feb 22, 2012

@author: daoxuandung
'''

"""
Provide URL routing for the whole website
"""

import webapp2
from google.appengine.ext import ndb
from webapp2_extras.routes import RedirectRoute

routes = [
          # Home page
          RedirectRoute('/home/', 
                      handler='web.home_page.HomePageHandler', 
                      name = 'home-page',
                      strict_slash=True),
          RedirectRoute('/home/like/<recipe_id:\d+>/', 
                      handler='web.home_page.LikeRecipeHandler', 
                      name = 'like-recipe',
                      strict_slash=True),

          RedirectRoute('/data/import/', 
                      handler='web.data.ImportDataHandler', 
                      name = 'import-data',
                      strict_slash=True),
          RedirectRoute('/data/delete/', 
                      handler='web.data.DeleteDataHandler', 
                      name = 'delete-data',
                      strict_slash=True)
          ]

config = {
          'webapp2_extras.sessions': {
                                      'secret_key': 'foo'
                                      } 
          }

#ndb.toplevel to make sure all async requests finish before handler exits
app = ndb.toplevel(webapp2.WSGIApplication(routes, config=config))